package com.vueblog.webapi.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.vueblog.webapi.enums.ResponseEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * <p>
 * 通用分页 返回对象
 * </p>
 *
 * @author intest
 * @since 2019-07-22
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class BasePageResponse<T> extends CommonResponse {

    /**
     * 总条数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Integer total;

    /**
     * 数据集
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<T> data;

    public BasePageResponse(Integer code, String message) {
        super(code, message);
    }

    public BasePageResponse(Integer code, String message, Integer total, List<T> data) {
        super(code, message);
        this.total = total;
        this.data = data;
    }

    public BasePageResponse(ResponseEnum re) {
        super(re);
    }

    public BasePageResponse(ResponseEnum re, Integer total, List<T> data) {
        super(re);
        this.total = total;
        this.data = data;
    }

    public BasePageResponse(Integer total, List<T> data) {
        this(ResponseEnum.SUCCESS, total, data);
    }
}
